<template>
	<div class="container">
		<div class="flex diygw-col-24">
			<el-form-item prop="editor" class="diygw-el-rate" label="多行输入" label-width="80px">
				<diy-editor v-model="editor"></diy-editor>
			</el-form-item>
		</div>
		<div class="clearfix"></div>
	</div>
</template>

<script>
	import { useRouter, useRoute } from 'vue-router';
	import { storeToRefs } from 'pinia';
	import { useUserInfo } from '@/stores/userInfo';

	import { ElMessageBox, ElMessage } from 'element-plus';

	import DiyEditor from '@/components/editor/index.vue';

	export default {
		components: {
			DiyEditor
		},
		data() {
			return {
				globalOption: {},
				userInfo: {},
				roleDatas: {
					rows: [
						{
							status: '',
							flag: '',
							remark: '',
							roleId: 0,
							roleName: '',
							roleKey: '',
							dataScope: '',
							roleSort: 0,
							createTime: '',
							updateTime: '',
							deleteTime: null,
							userId: null,
							updateUserId: null
						}
					],
					total: 0,
					code: 0,
					msg: ''
				},
				editor: ''
			};
		},
		methods: {
			getParamData(e, row) {
				row = row || {};
				let dataset = e.currentTarget ? e.currentTarget.dataset : e;
				if (row) {
					dataset = Object.assign(dataset, row);
				}
				return dataset;
			},
			navigateTo(e, row) {
				let dataset = this.getParamData(e, row);
				let { type } = dataset;
				if (type == 'page' || type == 'inner' || type == 'href') {
					this.router.push({
						path: dataset.url,
						query: dataset
					});
				} else if (typeof this[type] == 'function') {
					this[type](dataset);
				} else {
					ElMessage.error('待实现点击事件');
				}
			},
			async init() {},
			// 新增接口 API请求方法
			async roleDatasApi(param, data) {
				param = param || {};
				param = this.getParamData(param);
				let http_url = '/sys/role/all';
				let http_data = {
					tt: param.tt || '1',
					te: param.te || this.t523 || '123'
				};
				let http_header = {
					'Content-Type': 'application/json',
					'Content-Length': '123'
				};

				let roleDatas = await this.$http.post(http_url, http_data, http_header, 'json');
				this.roleDatas = roleDatas;
			}
		},
		async mounted() {
			this.router = useRouter();
			this.globalOption = useRoute().query;
			const stores = useUserInfo();
			const { userInfos } = storeToRefs(stores);
			this.userInfo = userInfos;
			await this.init();
		},
		beforeUnmount() {}
	};
</script>

<style lang="scss" scoped>
	.container {
		font-size: 12px;
	}
</style>
